import allure
from appium.webdriver.common.appiumby import AppiumBy


from src.day42.PO.search_results_page import SearchResultsPage
from src.day42.PO.xueqiu import XueQiu


class SearchPage(XueQiu):
    __SEARCH_INPUT=(AppiumBy.XPATH,"//*[@resource-id='com.xueqiu.android:id/search_input_text']")
    __SEARCH_LICK=(AppiumBy.XPATH,'//*[@resource-id="com.xueqiu.android:id/listview"]//*[@text="阿里巴巴"]')
    def search_input_click(self):
        with allure.step("向搜索输入框中输入【阿里巴巴】"):
            self.find_and_send(*self.__SEARCH_INPUT,text="阿里巴巴")
        with allure.step("点击搜索结果中的【阿里巴巴】，进入搜索结果页"):
            self.find_and_click(*self.__SEARCH_LICK)
        return SearchResultsPage(self.driver)


